 

$(function(){

/*
	usage:
	$("table.xx").pagination({
		pager : 'div',
		currentPage : 1 ,
		totalPage : 63
	});
 */
$.fn.pagination = function(setting){
		
	setting = $.extend({ 
	}, setting || {}); 
	
	return $(this).each(function(){
					 
		var pid = setting['pager'];
		
		var pcb = function( pageNum ){ 
			var url = window.location.href.toString();
			url = url.replace(/pageCurrentPage=[^&]*/g,'');
			var lastChr = url.charAt( url.length - 1);
			if( url.indexOf('?') > 0 ){
				if( lastChr == '?' || lastChr == '&'  ) {
					url = url + 'pageCurrentPage=' + pageNum;					
				} else {
					url = url + '&pageCurrentPage=' + pageNum;
				}
			} else {
				url = url + '?pageCurrentPage=' + pageNum;
			}
			window.location = url;
		}
 
		$( pid ).pager({  pagenumber:setting.currentPage , pagecount:setting.totalPage , buttonClickCallback:pcb  });
		if ( setting['recordCount'] && $(".pagination_record").length == 0 ) {
			$("<span>共" + setting['recordCount'] + "条</span>").insertAfter( $( pid ) );	
		}
	
	});
	
}

});